package com.litong.litongjiaoyu.config;

import com.litong.litongjiaoyu.interceptor.AuthorizationInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName AuthorizationConfig
 * @Description 权限拦截器配置
 * @Author jingz
 * @Date 2020/2/1 14:59
 * @Version 1.0
 **/
@Configuration
@EnableWebMvc
public class AuthorizationConfig extends WebMvcConfigurationSupport {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //可以有多个拦截器的注入，拦截方式这两也有两种
        //第一种是运用了自定义注解，在拦截中判断是否放行

        List<String> a = new ArrayList<>(3);
        a.add("/commen/getrecommend");
        a.add("/commen/getExcellentCourses");
        a.add("/commen/getAudition");
        a.add("/pic/**");
        a.add("/wxlogin");
        registry.addInterceptor(new AuthorizationInterceptor())
                .excludePathPatterns(a)
                .addPathPatterns("/**");
    }
}
